package com.swyc.osschat.Test.designMode.iterator.impl;

import com.swyc.osschat.Test.designMode.iterator.base.Aggregate;
import com.swyc.osschat.Test.designMode.iterator.base.Iterator;

import java.util.ArrayList;
import java.util.List;

/**
 * @description 具体聚合
 * @Author: z156940l@outlook.com
 * @className ObjectAggregate
 * @Date: 2022/6/28 8:45
 */
public class ObjectAggregate implements Aggregate {
    private List<Object> list = new ArrayList<>();

    @Override
    public void addObject(Object object) {
        list.add(object);
    }

    @Override
    public void removeObject(Object object) {
        list.remove(object);
    }

    @Override
    public Iterator getIterator() {
        return new ObjectIterator(list);
    }
}
